<?php
require 'inc_security.php';
$record_id = getValue('record_id');
$myform = new generate_form();
$myform->add('wah_name','wah_name',0,0,'Tiêu đề - mô tả slide');
$myform->add('wah_phone','wah_phone',0,0,'');
$myform->add('wah_address','wah_address',0,0,'');
$myform->addTable($bg_table);
$myform->removeHTML(0);
$action = getValue('action','str','POST','');
if($action == 'execute'){
    $bg_errorMsg .= $myform->checkdata();
    if($bg_errorMsg == ''){
        $db_insert = new db_execute($myform->generate_update_SQL($id_field,$record_id));
        redirect('listing.php');
    }
}
//lấy dữ liệu record cần sửa đổi
$db_data 	= new db_query("SELECT * FROM " . $bg_table . " WHERE " . $id_field . " = " . $record_id);
if($row 		= mysql_fetch_assoc($db_data->result)){
	foreach($row as $key=>$value){
		$$key = $value;
	}
}else{
		exit();
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?print_error_msg($bg_errorMsg)?>
    <?php $form = new form();
    ?>
    <?=$form->form_open()?>
    <?=$form->textnote('Các trường có dấu (<span class="form-asterick">*</span>) là bắt buộc nhập')?>
    <?=$form->text(array('label'=>'Tên kho','name'=>'wah_name','id'=>'wah_name','value'=>getValue('wah_name','str','POST',$wah_name), 'placeholder'=> 'Tên không dài quá 255 ký tự'),0,'span6')?>
    <?=$form->text(array('label'=>'Số điện thoại','name'=>'wah_phone','id'=>'wah_phone','value'=>getValue('wah_phone','str','POST',$wah_phone), 'placeholder'=> ''),0,'span6')?>
    <?=$form->text(array('label'=>'Địa chỉ','name'=>'wah_address','id'=>'wah_address','value'=>getValue('wah_address','str','POST',$wah_address), 'placeholder'=> ''),0,'span6')?>
	<?=$form->form_action(array('label'=>array('Cập nhật','Nhập lại'),'type'=>array('submit','reset')))?>
	<?=$form->form_close()?>
</div>
</body>
</html>